<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="root">
    <!--<h2 style="opacity: 1">欢迎学习vue</h2>-->
    <h2 :style="{opacity}">欢迎学习vue</h2>
</div>
<script src="../js/vue.js"></script>
<script>
    Vue.config.productionTip = false//阻止vue启动时产生提示
    new Vue({
        el: "#root",
        data: {//数据
            name: '',
            opacity: 1
        },
        methods: {//方法
            /*change(){
                setInterval(()=>{
                    this.opacity-=0.01
                    if (this.opacity<=0) this.opacity=1;
                },16)
            }*/
        },
        computed: {//计算

        },
        watch: {//监视

        },
        //vue完成模板的解析并且把初始的真实的DOM元素放入页面后调用mounted(挂载完毕)
        mounted() {//挂载
            setInterval(() => {
                this.opacity -= 0.01
                if (this.opacity <= 0) this.opacity = 1;
            }, 16)
        }
    })
</script>
</body>
</html>